
let starttime;//开始时间
let ye;//总条数;
let priv;//当前页数
let total;//总页数

//查询数据
function checkM() {
        $.ajax({
            url: "/meeting/message",
            type: "POST",
            dataType: "json",
            success: function (result) {
                var str="";
                if (result!=null){

                    for (let i = 0; i < result.data.length; i++) {
                        str+="<tr>\n" +
                            "\n" +
                            "            <td>"+result.data[i].title+"</td>\n" +
                            "            <td>"+result.data[i].time+"</td>\n" +
                            "            <td>"+result.data[i].entime+"</td>\n" +
                            "            <td>"+result.data[i].meetRoomPlace+"</td>\n" +
                            "            <td>"+result.data[i].meetRoomName+"</td>\n" +
                            "            <td>"+result.data[i].name+"</td>\n" +
                            "            <td><a href='test.html?meetid='+result.data[i].meetid+'\'>修改</a>\n" +
                            "                <a href=\"#\" class='a'>删除</a><i id='span' style='display: none'>"+result.data[i].meetid+"</i>\n";
                            // if (result.data[i].sign==1){
                                str+="<a href=\"#\" class='b'>提交记录</a><i id='span' style='display: none'>"+result.data[i].meetid+"</i>\n";
                                str+="<a href=\"checkOaRecord.html?meetid="+result.data[i].meetid+"\">查看记录</a>\n";
                            // }
                            str+="            </td>\n" +
                            "        </tr>"
                    }
                    //获取总条数

                    ye = result.totalRows;


                    //获取当前页

                    priv=result.pageNum;

                    //获取总页数

                    total=result.totalPage
                }
                $(".tablelist tbody").html(str);
                $(".pagin .message i:eq(0)").html(ye);
                $(".pagin .message i:eq(1)").html(priv);

                deleteMeeting();
                addOaRecord();
            }

        });

}

//删除会议信息
function deleteMeeting() {


        $(".a").click(function () {
            $(".tip").fadeIn(200);

            let index = $(".a").index(this);
            let meetid = $(".a:eq("+index+")").next("i").html();
            $(".sure").click(function(){

                $.ajax({
                    url:"/meeting/deleteMeeting",
                    type:"post",
                    data:{
                        "meetid":meetid
                    },
                    dataType:"json",
                    success:function (result) {
                        if (result==true){
                            alert("删除成功")
                        }else {
                            alert("删除失败")
                        }
                    }
                })
                $(".tip").fadeOut(100);
            });

        })

    $(".cancel").click(function(){
        $(".tip").fadeOut(100);
    });

}

//添加会议记录
function addOaRecord() {
    $(".b").click(function () {
        $(".tip").fadeIn(200);
        let index = $(".b").index(this);
        let meetid = $(".b:eq("+index+")").next("i").html();//会议id

        $(".sure").click(function(){

            $.ajax({
                url:"/meeting/addOaRecord",
                type:"post",
                data:{
                    "meetid":meetid
                },
                dataType:"json",
                success:function (result) {
                    if (result==true){
                        alert("添加成功")
                    }else {
                        alert("添加失败或已添加该记录")
                    }
                }
            })
            $(".tip").fadeOut(100);
        });

        $(".cancel").click(function(){
            $(".tip").fadeOut(100);
        });

    })

}


$(function () {
    checkM();

    //根据查询条件查询
    $(".prosearch .sure").click(function () {
        var title=$(".prosearch .scinput:eq(0)").val();//主题
        var meetRoomPlace=$(".prosearch .scinput:eq(1)").val();//会议地址
        var name=$(".prosearch .scinput:eq(2)").val();//主持人
        $.ajax({
            url: "/meeting/message",
            type: "POST",
            data:{"title":title,"meetRoomPlace":meetRoomPlace,"name":name},
            dataType: "json",
            success: function (result) {
                var str="";
                if (result!=null){
                    for (let i = 0; i < result.data.length; i++) {
                        str+="<tr>\n" +
                            "\n" +
                            "            <td>"+result.data[i].title+"</td>\n" +
                            "            <td>"+result.data[i].time+"</td>\n" +
                            "            <td>"+result.data[i].entime+"</td>\n" +
                            "            <td>"+result.data[i].meetRoomPlace+"</td>\n" +
                            "            <td>"+result.data[i].meetRoomName+"</td>\n" +
                            "            <td>"+result.data[i].name+"</td>\n" +
                            "            <td>\n" +
                            "                <a href=\"#\">修改</a>\n" +
                            "                <a href=\"#\">删除</a>\n" +
                            "            </td>\n" +
                            "        </tr>"
                    }
                    //获取总条数

                    ye = result.totalRows;


                    //获取当前页

                    priv=result.pageNum;

                    //获取总页数

                    total=result.totalPage
                }
                $(".tablelist tbody").html(str);
                $(".pagin .message i:eq(0)").html(ye);
                $(".pagin .message i:eq(1)").html(priv);

            }

        });
    })

    //首页
    $(".pagin .message a:eq(0)").click(function () {
        priv=1;
        $.ajax({
            url: "/meeting/message",
            type: "post",
            data: {"pageNum":priv},
            dataType: "json",
            success: function (result) {
                var str="";
                if (result!=null){

                    for (let i = 0; i < result.data.length; i++) {
                        str+="<tr>\n" +
                            "\n" +
                            "            <td>"+result.data[i].title+"</td>\n" +
                            "            <td>"+result.data[i].time+"</td>\n" +
                            "            <td>"+result.data[i].entime+"</td>\n" +
                            "            <td>"+result.data[i].meetRoomPlace+"</td>\n" +
                            "            <td>"+result.data[i].meetRoomName+"</td>\n" +
                            "            <td>"+result.data[i].name+"</td>\n" +
                            "            <td>\n" +
                            "                <a href=\"test.html?meetid="+result.data[i].meetid+"\">修改</a>\n" +
                            "                <a href=\"#\" class='a'>删除</a><i id='span' style='display: none'>"+result.data[i].meetid+"</i>\n";
                        // if (result.data[i].sign==1){
                            str+="<a href=\"#\" class='b'>提交记录</a><i id='span' style='display: none'>"+result.data[i].meetid+"</i>\n";
                            str+="<a href=\"checkOaRecord.html?meetid="+result.data[i].meetid+"\">查看记录</a>\n";
                        // }
                        str+="            </td>\n" +
                            "        </tr>"
                    }
                    //获取总条数

                    ye = result.totalRows;


                    //获取当前页

                    priv=result.pageNum;

                    //获取总页数

                    total=result.totalPage
                }
                $(".tablelist tbody").html(str);
                $(".pagin .message i:eq(0)").html(ye);
                $(".pagin .message i:eq(1)").html(priv);

                deleteMeeting();
            }


        })
    })

    //下一页
    $(".pagin .message a:eq(2)").click(function () {
        if (priv<total){
            priv=priv+1;
            $.ajax({
                url: "/meeting/message",
                type: "post",
                data: {"pageNum":priv},
                dataType: "json",
                success: function (result) {
                    var str="";
                    if (result!=null){

                        for (let i = 0; i < result.data.length; i++) {
                            str+="<tr>\n" +
                                "\n" +
                                "            <td>"+result.data[i].title+"</td>\n" +
                                "            <td>"+result.data[i].time+"</td>\n" +
                                "            <td>"+result.data[i].entime+"</td>\n" +
                                "            <td>"+result.data[i].meetRoomPlace+"</td>\n" +
                                "            <td>"+result.data[i].meetRoomName+"</td>\n" +
                                "            <td>"+result.data[i].name+"</td>\n" +
                                "            <td>\n" +
                                "                <a href=\"test.html?meetid="+result.data[i].meetid+"\">修改</a>\n" +
                                "                <a href=\"#\" class='a'>删除</a><i id='span' style='display: none'>"+result.data[i].meetid+"</i>\n";
                            // if (result.data[i].sign==1){
                                str+="<a href=\"#\" class='b'>提交记录</a><i id='span' style='display: none'>"+result.data[i].meetid+"</i>\n";
                                str+="<a href=\"checkOaRecord.html?meetid="+result.data[i].meetid+"\">查看记录</a>\n";
                            // }
                            str+="            </td>\n" +
                                "        </tr>"
                        }
                        //获取总条数

                        ye = result.totalRows;


                        //获取当前页

                        priv=result.pageNum;

                        //获取总页数

                        total=result.totalPage
                    }
                    $(".tablelist tbody").html(str);
                    $(".pagin .message i:eq(0)").html(ye);
                    $(".pagin .message i:eq(1)").html(priv);

                    deleteMeeting();
                    addOaRecord();
                }


            })
        }

    })

    //上一页
    $(".pagin .message a:eq(1)").click(function () {
        if (priv>1){
            priv=priv-1;
            $.ajax({
                url: "/meeting/message",
                type: "post",
                data: {"pageNum":priv},
                dataType: "json",
                success: function (result) {
                    var str="";
                    if (result!=null){

                        for (let i = 0; i < result.data.length; i++) {
                            str+="<tr>\n" +
                                "\n" +
                                "            <td>"+result.data[i].title+"</td>\n" +
                                "            <td>"+result.data[i].time+"</td>\n" +
                                "            <td>"+result.data[i].entime+"</td>\n" +
                                "            <td>"+result.data[i].meetRoomPlace+"</td>\n" +
                                "            <td>"+result.data[i].meetRoomName+"</td>\n" +
                                "            <td>"+result.data[i].name+"</td>\n" +
                                "            <td>\n" +
                                "                <a href=\"test.html?meetid="+result.data[i].meetid+"\">修改</a>\n" +
                                "                <a href=\"#\" class='a'>删除</a><i id='span' style='display: none'>"+result.data[i].meetid+"</i>\n";
                            // if (result.data[i].sign==1){
                            str+="<a href=\"#\" class='b'>提交记录</a><i id='span' style='display: none'>"+result.data[i].meetid+"</i>\n";
                            str+="<a href=\"checkOaRecord.html?meetid="+result.data[i].meetid+"\">查看记录</a>\n";
                            // }
                            str+="            </td>\n" +
                                "        </tr>"
                        }
                        //获取总条数

                        ye = result.totalRows;


                        //获取当前页

                        priv=result.pageNum;

                        //获取总页数

                        total=result.totalPage
                    }
                    $(".tablelist tbody").html(str);
                    $(".pagin .message i:eq(0)").html(ye);
                    $(".pagin .message i:eq(1)").html(priv);

                    deleteMeeting();
                    addOaRecord();
                }


            })
        }

    })

    //尾页
    $(".pagin .message a:eq(3)").click(function () {

            priv=total;
            $.ajax({
                url: "/meeting/message",
                type: "post",
                data: {"pageNum":priv},
                dataType: "json",
                success: function (result) {
                    var str="";
                    if (result!=null){

                        for (let i = 0; i < result.data.length; i++) {
                            str+="<tr>\n" +
                                "\n" +
                                "            <td>"+result.data[i].title+"</td>\n" +
                                "            <td>"+result.data[i].time+"</td>\n" +
                                "            <td>"+result.data[i].entime+"</td>\n" +
                                "            <td>"+result.data[i].meetRoomPlace+"</td>\n" +
                                "            <td>"+result.data[i].meetRoomName+"</td>\n" +
                                "            <td>"+result.data[i].name+"</td>\n" +
                                "            <td>\n" +
                                "                <a href=\"test.html?meetid="+result.data[i].meetid+"\">修改</a>\n" +
                                "                <a href=\"#\" class='a'>删除</a><i id='span' style='display: none'>"+result.data[i].meetid+"</i>\n";
                            // if (result.data[i].sign==1){
                            str+="<a href=\"#\" class='b'>提交记录</a><i id='span' style='display: none'>"+result.data[i].meetid+"</i>\n";
                            str+="<a href=\"checkOaRecord.html?meetid="+result.data[i].meetid+"\">查看记录</a>\n";
                            // }
                            str+="            </td>\n" +
                                "        </tr>"
                        }
                        //获取总条数

                        ye = result.totalRows;


                        //获取当前页

                        priv=result.pageNum;

                        //获取总页数

                        total=result.totalPage
                    }
                    $(".tablelist tbody").html(str);
                    $(".pagin .message i:eq(0)").html(ye);
                    $(".pagin .message i:eq(1)").html(priv);

                    deleteMeeting();
                    addOaRecord();
                }


            })


    })

    //左箭头
    $(".paginList li:eq(0)").click(function () {
        if (priv>1){
            priv=priv-1;
            $.ajax({
                url: "/meeting/message",
                type: "post",
                data: {"pageNum":priv},
                dataType: "json",
                success: function (result) {
                    var str="";
                    if (result!=null){

                        for (let i = 0; i < result.data.length; i++) {
                            str+="<tr>\n" +
                                "\n" +
                                "            <td>"+result.data[i].title+"</td>\n" +
                                "            <td>"+result.data[i].time+"</td>\n" +
                                "            <td>"+result.data[i].entime+"</td>\n" +
                                "            <td>"+result.data[i].meetRoomPlace+"</td>\n" +
                                "            <td>"+result.data[i].meetRoomName+"</td>\n" +
                                "            <td>"+result.data[i].name+"</td>\n" +
                                "            <td>\n" +
                                "                <a href=\"test.html?meetid="+result.data[i].meetid+"\">修改</a>\n" +
                                "                <a href=\"#\" class='a'>删除</a><i id='span' style='display: none'>"+result.data[i].meetid+"</i>\n";
                            // if (result.data[i].sign==1){
                            str+="<a href=\"#\" class='b'>提交记录</a><i id='span' style='display: none'>"+result.data[i].meetid+"</i>\n";
                            str+="<a href=\"checkOaRecord.html?meetid="+result.data[i].meetid+"\">查看记录</a>\n";
                            // }
                            str+="            </td>\n" +
                                "        </tr>"
                        }
                        //获取总条数

                        ye = result.totalRows;


                        //获取当前页

                        priv=result.pageNum;

                        //获取总页数

                        total=result.totalPage
                    }
                    $(".tablelist tbody").html(str);
                    $(".pagin .message i:eq(0)").html(ye);
                    $(".pagin .message i:eq(1)").html(priv);

                    deleteMeeting();
                    addOaRecord();
                }


            })
        }
    })

    //第一页
    $(".paginList li:eq(1)").click(function () {

            priv=1;
            $.ajax({
                url: "/meeting/message",
                type: "post",
                data: {"pageNum":priv},
                dataType: "json",
                success: function (result) {
                    var str="";
                    if (result!=null){

                        for (let i = 0; i < result.data.length; i++) {
                            str+="<tr>\n" +
                                "\n" +
                                "            <td>"+result.data[i].title+"</td>\n" +
                                "            <td>"+result.data[i].time+"</td>\n" +
                                "            <td>"+result.data[i].entime+"</td>\n" +
                                "            <td>"+result.data[i].meetRoomPlace+"</td>\n" +
                                "            <td>"+result.data[i].meetRoomName+"</td>\n" +
                                "            <td>"+result.data[i].name+"</td>\n" +
                                "            <td>\n" +
                                "                <a href=\"test.html?meetid="+result.data[i].meetid+"\">修改</a>\n" +
                                "                <a href=\"#\" class='a'>删除</a><i id='span' style='display: none'>"+result.data[i].meetid+"</i>\n";
                            // if (result.data[i].sign==1){
                            str+="<a href=\"#\" class='b'>提交记录</a><i id='span' style='display: none'>"+result.data[i].meetid+"</i>\n";
                            str+="<a href=\"checkOaRecord.html?meetid="+result.data[i].meetid+"\">查看记录</a>\n";
                            // }
                            str+="            </td>\n" +
                                "        </tr>"
                        }
                        //获取总条数

                        ye = result.totalRows;


                        //获取当前页

                        priv=result.pageNum;

                        //获取总页数

                        total=result.totalPage
                    }
                    $(".tablelist tbody").html(str);
                    $(".pagin .message i:eq(0)").html(ye);
                    $(".pagin .message i:eq(1)").html(priv);

                    deleteMeeting();
                    addOaRecord();
                }


            })

    })
    //第二页

    $(".paginList li:eq(2)").click(function () {

            priv=2;
            $.ajax({
                url: "/meeting/message",
                type: "post",
                data: {"pageNum":priv},
                dataType: "json",
                success: function (result) {
                    var str="";
                    if (result!=null){

                        for (let i = 0; i < result.data.length; i++) {
                            str+="<tr>\n" +
                                "\n" +
                                "            <td>"+result.data[i].title+"</td>\n" +
                                "            <td>"+result.data[i].time+"</td>\n" +
                                "            <td>"+result.data[i].entime+"</td>\n" +
                                "            <td>"+result.data[i].meetRoomPlace+"</td>\n" +
                                "            <td>"+result.data[i].meetRoomName+"</td>\n" +
                                "            <td>"+result.data[i].name+"</td>\n" +
                                "            <td>\n" +
                                "                <a href=\"test.html?meetid="+result.data[i].meetid+"\">修改</a>\n" +
                                "                <a href=\"#\" class='a'>删除</a><i id='span' style='display: none'>"+result.data[i].meetid+"</i>\n";
                            // if (result.data[i].sign==1){
                            str+="<a href=\"#\" class='b'>提交记录</a><i id='span' style='display: none'>"+result.data[i].meetid+"</i>\n";
                            str+="<a href=\"checkOaRecord.html?meetid="+result.data[i].meetid+"\">查看记录</a>\n";
                            // }
                            str+="            </td>\n" +
                                "        </tr>"
                        }
                        //获取总条数

                        ye = result.totalRows;


                        //获取当前页

                        priv=result.pageNum;

                        //获取总页数

                        total=result.totalPage
                    }
                    $(".tablelist tbody").html(str);
                    $(".pagin .message i:eq(0)").html(ye);
                    $(".pagin .message i:eq(1)").html(priv);

                    deleteMeeting();
                    addOaRecord();
                }


            })

    })
    //第三页

    $(".paginList li:eq(3)").click(function () {

            priv=3;
            $.ajax({
                url: "/meeting/message",
                type: "post",
                data: {"pageNum":priv},
                dataType: "json",
                success: function (result) {
                    var str="";
                    if (result!=null){

                        for (let i = 0; i < result.data.length; i++) {
                            str+="<tr>\n" +
                                "\n" +
                                "            <td>"+result.data[i].title+"</td>\n" +
                                "            <td>"+result.data[i].time+"</td>\n" +
                                "            <td>"+result.data[i].entime+"</td>\n" +
                                "            <td>"+result.data[i].meetRoomPlace+"</td>\n" +
                                "            <td>"+result.data[i].meetRoomName+"</td>\n" +
                                "            <td>"+result.data[i].name+"</td>\n" +
                                "            <td>\n" +
                                "                <a href=\"test.html?meetid="+result.data[i].meetid+"\">修改</a>\n" +
                                "                <a href=\"#\" class='a'>删除</a><i id='span' style='display: none'>"+result.data[i].meetid+"</i>\n";
                            // if (result.data[i].sign==1){
                            str+="<a href=\"#\" class='b'>提交记录</a><i id='span' style='display: none'>"+result.data[i].meetid+"</i>\n";
                            str+="<a href=\"checkOaRecord.html?meetid="+result.data[i].meetid+"\">查看记录</a>\n";
                            // }
                            str+="            </td>\n" +
                                "        </tr>"
                        }
                        //获取总条数

                        ye = result.totalRows;


                        //获取当前页

                        priv=result.pageNum;

                        //获取总页数

                        total=result.totalPage
                    }
                    $(".tablelist tbody").html(str);
                    $(".pagin .message i:eq(0)").html(ye);
                    $(".pagin .message i:eq(1)").html(priv);

                    deleteMeeting();
                    addOaRecord();
                }


            })

    })
    //第四页

    $(".paginList li:eq(4)").click(function () {

            priv=4;
            $.ajax({
                url: "/meeting/message",
                type: "post",
                data: {"pageNum":priv},
                dataType: "json",
                success: function (result) {
                    var str="";
                    if (result!=null){

                        for (let i = 0; i < result.data.length; i++) {
                            str+="<tr>\n" +
                                "\n" +
                                "            <td>"+result.data[i].title+"</td>\n" +
                                "            <td>"+result.data[i].time+"</td>\n" +
                                "            <td>"+result.data[i].entime+"</td>\n" +
                                "            <td>"+result.data[i].meetRoomPlace+"</td>\n" +
                                "            <td>"+result.data[i].meetRoomName+"</td>\n" +
                                "            <td>"+result.data[i].name+"</td>\n" +
                                "            <td>\n" +
                                "                <a href=\"test.html?meetid="+result.data[i].meetid+"\">修改</a>\n" +
                                "                <a href=\"#\" class='a'>删除</a><i id='span' style='display: none'>"+result.data[i].meetid+"</i>\n";
                            // if (result.data[i].sign==1){
                            str+="<a href=\"#\" class='b'>提交记录</a><i id='span' style='display: none'>"+result.data[i].meetid+"</i>\n";
                            str+="<a href=\"checkOaRecord.html?meetid="+result.data[i].meetid+"\">查看记录</a>\n";
                            // }
                            str+="            </td>\n" +
                                "        </tr>"
                        }
                        //获取总条数

                        ye = result.totalRows;


                        //获取当前页

                        priv=result.pageNum;

                        //获取总页数

                        total=result.totalPage
                    }
                    $(".tablelist tbody").html(str);
                    $(".pagin .message i:eq(0)").html(ye);
                    $(".pagin .message i:eq(1)").html(priv);

                    deleteMeeting();
                    addOaRecord();
                }


            })

    })
    //第五页
    $(".paginList li:eq(5)").click(function () {

            priv=5;
            $.ajax({
                url: "/meeting/message",
                type: "post",
                data: {"pageNum":priv},
                dataType: "json",
                success: function (result) {
                    var str="";
                    if (result!=null){

                        for (let i = 0; i < result.data.length; i++) {
                            str+="<tr>\n" +
                                "\n" +
                                "            <td>"+result.data[i].title+"</td>\n" +
                                "            <td>"+result.data[i].time+"</td>\n" +
                                "            <td>"+result.data[i].entime+"</td>\n" +
                                "            <td>"+result.data[i].meetRoomPlace+"</td>\n" +
                                "            <td>"+result.data[i].meetRoomName+"</td>\n" +
                                "            <td>"+result.data[i].name+"</td>\n" +
                                "            <td>\n" +
                                "                <a href=\"test.html?meetid="+result.data[i].meetid+"\">修改</a>\n" +
                                "                <a href=\"#\" class='a'>删除</a><i id='span' style='display: none'>"+result.data[i].meetid+"</i>\n";
                            // if (result.data[i].sign==1){
                            str+="<a href=\"#\" class='b'>提交记录</a><i id='span' style='display: none'>"+result.data[i].meetid+"</i>\n";
                            str+="<a href=\"checkOaRecord.html?meetid="+result.data[i].meetid+"\">查看记录</a>\n";
                            // }
                            str+="            </td>\n" +
                                "        </tr>"
                        }
                        //获取总条数

                        ye = result.totalRows;


                        //获取当前页

                        priv=result.pageNum;

                        //获取总页数

                        total=result.totalPage
                    }
                    $(".tablelist tbody").html(str);
                    $(".pagin .message i:eq(0)").html(ye);
                    $(".pagin .message i:eq(1)").html(priv);

                    deleteMeeting();
                    addOaRecord();
                }


            })

    })
})